﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CMP.ERP.BLL;
using CMP.ERP.Model;
using System.Data;
namespace CMP.ERP.Admin.Controllers
{
    public class HomeController : Controller
    {
        //
        // GET: /Home/
        UsersBLL bll = new UsersBLL();
        /// <summary>
        /// 弹出登录视图
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public ActionResult Login(string name, string pwd)
        {
            return View();
        }
        /// <summary>
        /// 实现登陆功能
        /// </summary>
        /// <param name="name"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public ActionResult Logindiet(string name, string pwd)
        {
            Session["name"] = name;
            if (bll.GetShow(name, pwd))
            {
                return Content("True");
            }
            else
            {
                return Content("Fales");
            }
        }
        /// <summary>
        /// 弹出注册视图
        /// </summary>
        /// <param name="b"></param>
        /// <returns></returns>
        public ActionResult zhuce()
        {
            return View();
        }
        /// <summary>
        /// 实现注册功能
        /// </summary>
        /// <param name="c"></param>
        /// <returns></returns>
        public ActionResult zhucebb(Users c)
        {
            c.Ustate = "正常";
           
                if (bll.GetShow1(c.UName)==0)
                {
                    if (bll.Getadd(c))
                    {
                    return Content("1"); 
                    }
                    else
                    {
                        return Content("2");
                    }
                }
            else
            {
                return Content("0");
            }
        }
        /// <summary>
        /// 弹出首页面
        /// </summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            StockBLL bll = new StockBLL();
            ShipmentsBLL cbll = new ShipmentsBLL();
            Session["Count"] = bll.Countearly();
            Session["weop"] = cbll.shu();
            Session["weop1"] = cbll.shu1();
            Session["Oneday"] = cbll.ShowOneday();
            Session["Threeday"] = cbll.ShowThreeday();
            Session["Sixday"] = cbll.ShowSixday();
            Session["Sevenday"] = cbll.ShowSevenday();
            return View();
        }

        public ActionResult Index1()
        {
            return View();
        }
        public ActionResult Kucunjingjie()
        {
            StockBLL sbll = new StockBLL();
            List<Stock> list = new List<Stock>();
            DataTable data = sbll.Jingjie();
            foreach (DataRow item in data.Rows)
            {
                Stock s = new Stock();
                //s.Supplier_Id = Convert.ToInt32(item["Supplier_Id"]);
                //s.Supplier_Name = item["Supplier_Name"].ToString();
                s.Stock_Id = Convert.ToInt32(item["Stock_Id"]);
                s.Commodity_Name = item["Commodity_Name"].ToString();
                s.WareHose_Name = item["WareHose_Name"].ToString();
                s.Stock_Num = Convert.ToInt32(item["Stock_Num"]);
                list.Add(s);

            }
            return View(list);

        }
    }
}